from pedestrian.models import Auth, SolutionAllotment, SolutionSafety
from pedestrian.extensions import db
from faker import Faker
from datetime import datetime

import random

fake = Faker('zh_CN')


def fake_auth(count=50):
    for i in range(count):
        auth = Auth(
            telephone=fake.telephone(),
            username=fake.name(),
            password_hash=fake.password(length=15),
            mail=fake.email()
        )
        db.session.add(auth)
    db.session.commit()


def fake_solutionSafety(count=100):
    for i in range(count):
        solutionSafety = SolutionSafety(
            time=datetime.now(),
            numbers=fake.random_digit(),
            auth_id=Auth.query.get(random.randint(1, Auth.query.count()))
        )
        db.session.add(solutionSafety)
    db.session.commit()


def fake_solutionAllotment(count=100):
    for i in range(count):
        solutionAllotment = SolutionAllotment(
            time=datetime.now(),
            numbers=fake.random_digit(),
            auth_id=Auth.query.get(random.randint(1, Auth.query.count()))
        )
        db.session.add(solutionAllotment)
    db.session.commit()
